import { useEffect, useState } from 'react'
import axios from 'axios'
import { API } from '../config'


export default function useGetCategories(){
  const [ catgories, setCategories ] = useState([])
  useEffect(() => {
    async function getCatgory(){
      let res = await axios.get(`${API}/categories`)
      setCategories(res.data)
    }
    getCatgory()
  },[])
  return catgories
}